package cn.funnyxb.powerremember.tts;

import android.content.Context;
import android.os.Environment;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
import android.widget.Toast;
import cn.funnyxb.tools.appFrame.App;
import cn.funnyxb.tools.appFrame.debugTool.Debuger;
import java.io.File;
import java.util.HashMap;
import java.util.Locale;

public class TTSHolder
{
  public static final int TTSSTATE_FAIL_4LANGUAGE = 103;
  public static final int TTSSTATE_FAIL_4ROM = 105;
  public static final int TTSSTATE_FAIL_CHECK = 109;
  public static final int TTSSTATE_FAIL_UNKNOWN = 110;
  public static final int TTSSTATE_FAIL_UNSURPOT = 102;
  public static final int TTSSTATE_SUCCESS = 100;
  public static final int TTSSTATE_VOICE_DATA_BAD = 106;
  public static final int TTSSTATE_VOICE_DATA_MISS = 107;
  public static final int TTSSTATE_VOICE_VOLUME_MISS = 108;
  private static TextToSpeech tts;
  private static int ttsState = -1;
  private Context context;
  private boolean ttsLoadFullCompleted = false;

  static
  {
    tts = null;
  }

  public TTSHolder(Context paramContext)
  {
    this.context = paramContext;
  }

  private void initTtsCompleted()
  {
    int i = tts.setLanguage(Locale.US);
    if ((i == -1) || (i == -2))
    {
      int j = tts.setLanguage(Locale.ENGLISH);
      if ((j == -1) || (j == -2));
    }
    while (true)
    {
      return;
      if (1 != 0)
      {
        ttsState = 100;
        tts.speak("okay,   text to speech    prepared!", 0, null);
      }
      ttsState = 103;
      tts = null;
      Toast.makeText(this.context, 2131034183, 1).show();
    }
  }

  private void log(String paramString)
  {
    Debuger.log("ttsholder", paramString);
  }

  public int getTTSState()
  {
    return ttsState;
  }

  public TextToSpeech getTextToSpeech()
  {
    return tts;
  }

  public void initTextToSpeech4TTSIsInstalled()
  {
    if (tts != null)
    {
      tts.stop();
      tts.shutdown();
    }
    MyOnInitListener localMyOnInitListener = new MyOnInitListener(null);
    tts = new TextToSpeech(this.context, localMyOnInitListener);
  }

  public boolean isTtsFunctionClose()
  {
    boolean bool1;
    try
    {
      boolean bool2 = new File(Environment.getExternalStorageDirectory() + File.separator + "powerRemember.closeTTS").exists();
      bool1 = bool2;
      return bool1;
    }
    catch (Exception localException)
    {
      bool1 = false;
    }
  }

  public boolean isTtsLoadFullCompleted()
  {
    return this.ttsLoadFullCompleted;
  }

  public void setTTSState(int paramInt)
  {
    ttsState = paramInt;
  }

  public void setTtsLoadFullCompleted()
  {
    this.ttsLoadFullCompleted = true;
  }

  public void shutdown()
  {
    if (tts == null)
      return;
    tts.shutdown();
  }

  public void speech(Context paramContext, NotifyOnceHelper paramNotifyOnceHelper, String paramString, int paramInt, HashMap<String, String> paramHashMap)
  {
    TTSHolder localTTSHolder = App.getApp().getTTSHolder();
    log("ttsHolder.isTtsFunctionClose=" + localTTSHolder.isTtsFunctionClose());
    if (localTTSHolder.isTtsFunctionClose())
      paramNotifyOnceHelper.ttsIsNotSupported();
    while (true)
    {
      return;
      log("ttsHolder.isTtsFunctionClose=" + localTTSHolder.isTtsFunctionClose());
      if (!(localTTSHolder.isTtsLoadFullCompleted()))
      {
        Toast.makeText(paramContext, 2131034186, 0);
        paramNotifyOnceHelper.ttsIsNotSupported();
      }
      if ((tts == null) || (localTTSHolder.getTTSState() != 100))
      {
        log("tts not support");
        if ((paramNotifyOnceHelper != null) && (paramNotifyOnceHelper.isNeedNotify()))
        {
          paramNotifyOnceHelper.setNeedNotify(false);
          Toast.makeText(paramContext, 2131034187, 1).show();
        }
        paramNotifyOnceHelper.ttsIsNotSupported();
      }
      log("speech");
      tts.speak(paramString, paramInt, paramHashMap);
    }
  }

  private class MyOnInitListener
    implements TextToSpeech.OnInitListener
  {
    public void onInit(int paramInt)
    {
      if (paramInt == 0)
        TTSHolder.this.initTtsCompleted();
      while (true)
      {
        TTSHolder.this.ttsLoadFullCompleted = true;
        return;
        TTSHolder.ttsState = 102;
        TTSHolder.tts = null;
      }
    }
  }

  public static class NotifyOnceHelper
  {
    private boolean needNotify = true;

    public boolean isNeedNotify()
    {
      return this.needNotify;
    }

    public void setNeedNotify(boolean paramBoolean)
    {
      this.needNotify = paramBoolean;
    }

    public void ttsIsNotSupported()
    {
    }
  }
}

/* Location:           E:\Desktop\复件 classes_dex2jar.jar
 * Qualified Name:     cn.funnyxb.powerremember.tts.TTSHolder
 * JD-Core Version:    0.5.3
 */